import 'dart:convert';
import 'package:ichinesereader/models/knowledgeword/knowledgeFolderTreeResult.dart';

KnowledgeWord knowledgeWordFromJson(String str) =>
    KnowledgeWord.fromJson(json.decode(str));

String knowledgeWordToJson(KnowledgeWord data) => json.encode(data.toJson());

class KnowledgeWord {
  KnowledgeWord({
    this.pinyinNumber,
    this.image,
    this.radical,
    this.level,
    this.stroke,
    this.example,
    this.pinyin,
    this.commitTime,
    this.definition,
    this.id,
    this.teacherId,
    this.text,
    this.audio,
    this.category,
    this.folders,
    this.folderId,
    this.checked,
    this.shareStudents,
  });

  String? pinyinNumber;
  String? image;
  String? radical;
  int? level;
  int? stroke;
  List<String>? example;
  String? pinyin;
  int? commitTime;
  dynamic definition;
  String? id;
  String? teacherId;
  String? text;
  String? audio;
  String? category;
  List<WordFolder>? folders;
  String? folderId;
  bool? checked;
  List<String>? shareStudents;

  factory KnowledgeWord.fromJson(Map<String, dynamic> json) => KnowledgeWord(
        pinyinNumber: json["pinyinNumber"],
        image: json["image"] == null ? null : json["image"],
        radical: json["radical"] == null ? null : json["radical"],
        level: json["level"],
        stroke: json["stroke"] == null ? null : json["stroke"],
        example: json["example"] != null
            ? List<String>.from(json["example"].map((x) => x))
            : null,
        pinyin: json["pinyin"],
        commitTime: json["commitTime"],
        definition: json["definition"] == null ? null : json["definition"],
        id: json["id"],
        teacherId: json["teacherId"],
        text: json["text"],
        audio: json["audio"],
        category: json["category"] == null ? null : json["category"],
        folderId: json["folderId"] == null ? null : json["folderId"],
        folders: json["folders"] != null
            ? List<WordFolder>.from(
                json["folders"].map((x) => WordFolder.fromJson(x)))
            : null,
        checked: json["checked"] == null ? false : json["checked"],
        shareStudents: json["shareStudents"] != null
            ? List<String>.from(json["shareStudents"].map((x) => x))
            : null,
      );

  Map<String, dynamic> toJson() => {
        // "pinyinNumber": pinyinNumber,
        "image": image == null ? null : image,
        // "radical": radical == null ? null : radical,
        // "level": level,
        // "stroke": stroke == null ? null : stroke,
        "example":
            example != null ? List<dynamic>.from(example!.map((x) => x)) : null,
        "pinyin": pinyin,
        // "commitTime": commitTime,
        "definition": definition == null ? null : definition,
        // "id": id,
        "text": text,
        "audio": audio,
        "category": category == null ? null : category,
        // "folderId": category == null ? null : folderId,
        // "folders": List<dynamic>.from(folders!.map((x) => x.toJson())),
        // "checked": checked == null ? null : checked,
      };
}
